<?php use_stylesheets_for_form($form) ?>
<?php use_javascripts_for_form($form) ?>

  <?php echo form_tag_for($form, '@banner_group') ?>
    <?php echo $form->renderHiddenFields(false) ?>

    <?php if ($form->hasGlobalErrors()): ?>
      <?php echo $form->renderGlobalErrors() ?>
    <?php endif; ?>

<table>

	<tfoot align="left">
		<tr align="left">
			<td align="left" colspan="10" ><input style="float:left;" type="submit" name="Salvesta" value="<?php echo __('Save')?>" class="formInput" /></td>
		</tr>		
	</tfoot>
	<tbody>
		<tr>
			<td><?php echo $form['name']->renderLabel('', array( 'class' => 'formLabel' ))?></td>
			<td> <?php echo $form['name']->render(array( 'class' => 'formInput' ))?> </td>
			<td><?php echo $form['name']->renderError()?></td>
		</tr>
		<tr>
			<td><?php echo $form['description']->renderLabel('', array( 'class' => 'formLabel' ))?></td>
			<td> <?php echo $form['description']->render(array( 'class' => 'formInput' ))?> </td>
			<td><?php echo $form['description']->renderError()?></td>
		</tr>
		<tr>
			<td><?php echo $form['pri']->renderLabel('Priority', array( 'class' => 'formLabel' ))?></td>
			<td> <?php echo $form['pri']->render(array( 'class' => 'formInput' ))?> </td>
			<td><?php echo $form['pri']->renderError()?></td>
		</tr>
		
		<tr>
			<td><?php echo $form['type']->renderLabel('', array( 'class' => 'formLabel' ))?></td>
			<td> <?php echo $form['type']->render(array( 'class' => 'formInput' ))?> </td>
			<td><?php echo $form['type']->renderError()?></td>
		</tr>
		
		<tr>
			<td><?php echo $form['height']->renderLabel('', array( 'class' => 'formLabel' ))?></td>
			<td> <?php echo $form['height']->render(array( 'class' => 'formInput' ))?> </td>
			<td><?php echo $form['height']->renderError()?></td>
		</tr>
		<tr>
			<td><?php echo $form['width']->renderLabel('', array( 'class' => 'formLabel' ))?></td>
			<td> <?php echo $form['width']->render(array( 'class' => 'formInput' ))?> </td>
			<td><?php echo $form['width']->renderError()?></td>
		</tr>
		
		<tr>
			<td><?php echo $form['is_active']->renderLabel('', array( 'class' => 'formLabel' ))?></td>
			<td> <?php echo $form['is_active']->render(array( 'class' => 'formInput' ))?> </td>
			<td><?php echo $form['is_active']->renderError()?></td>
		</tr>
		
		<tr>
			<td><?php echo $form['banners_limit']->renderLabel('', array( 'class' => 'formLabel' ))?></td>
			<td> <?php echo $form['banners_limit']->render(array( 'class' => 'formInput' ))?> </td>
			<td><?php echo $form['banners_limit']->renderError()?></td>
		</tr>
		
		<tr>
			<td><?php echo $form['connections']->renderLabel('', array( 'class' => 'formLabel' ))?></td>
			<td> <?php echo $form['connections']->render(array( 'class' => 'formInput' ))?> </td>
			<td><?php echo $form['connections']->renderError()?></td>
		</tr>
	</tbody>
	
</table>


<?php if(!$form->isNew()): ?>
<h2><?php echo __('Banners in banner group') ?></h2>

<table style="width:45%;float:left;">

	<?php foreach($form->getObject()->getBanners() as $banner): ?>
	<tr>
	    <td>
			<a href="<?php echo url_for('@banner_edit?id='.$banner['id']) ?>"><?php echo @$banner->getPictureImg() ?></a>
		</td>
	    <td>
			<div class="deletebutton" style="float:right;padding-top:10px">
				<a href="<?php echo url_for('admin_page', array(
					'action'=>'bannerDelete',
					'module' => 'bannergroup',
					'bannerID'=>$banner['id'])) ?>"><?php echo __('Delete') ?></a>
			</div>
		</td>
	</tr>
	<?php endforeach; ?>
    
</table>
<div style="float:left;width:20px">&nbsp;</div>
<?php include_partial('bannergroup/fileupload') ?>
<div class="clear"></div>


<?php endif; ?>
</form>

<script type="text/javascript">
	$('.deletebutton').click(function(e){
		return window.confirm('Are you sure ?');
	});
</script>